package Menu;

import PasswordJudge.PasswordJudge;
import RandomPassword.RandomPassword;
import passwordEncryption.Encryption;

import java.util.Scanner;

public class Menu {
    public static void main(String[] args) {
        menu();
    }

    public static void menu() {
        Scanner scanner = new Scanner(System.in);

        boolean out = true;
        while (out != false) {
            System.out.println("=================");
            System.out.println("欢迎使用密码管理系统");
            System.out.println("=================");
            System.out.println("请选择操作：");
            System.out.println("1.加密");
            System.out.println("2.解密");
            System.out.println("3.判断密码强度");
            System.out.println("4.密码生成");
            System.out.println("5.退出");
            System.out.print("请选择输入序号：");
            switch (scanner.nextInt()){
                case 1:encryption();break;
                case 2:decode();break;
                case 3:judge();break;
                case 4:random();break;
                case 5:out = false;break;
            }
        }
    }

    public static void encryption(){
        Encryption encryption = new Encryption();
        System.out.println("=================");
        System.out.println("欢迎使用密码管理系统");
        System.out.println("=================");
        System.out.println("请输入要加密的密码：");
        Scanner scanner = new Scanner(System.in);
        String ps = scanner.nextLine();
        System.out.println("加密后的结果是："+encryption.encryption(ps));
    }

    public static void decode(){
        Encryption encryption = new Encryption();
        System.out.println("=================");
        System.out.println("欢迎使用密码管理系统");
        System.out.println("=================");
        System.out.println("请输入要解密的密码：");
        Scanner scanner = new Scanner(System.in);
        String ps = scanner.nextLine();
        System.out.println("解密后的结果是："+encryption.decode(ps));
    }

    public static void judge(){
        PasswordJudge passwordJudge = new PasswordJudge();
        System.out.println("=================");
        System.out.println("欢迎使用密码管理系统");
        System.out.println("=================");
        System.out.println("请输入您的密码：");
        Scanner scanner = new Scanner(System.in);
        String ps = scanner.nextLine();
        if(passwordJudge.hight(ps)){
            System.out.println("高强度密码");
        }else if (passwordJudge.mid(ps)){
            System.out.println("中强度密码");
        }else if (passwordJudge.low(ps)){
            System.out.println("弱强度密码");
        }
    }

    public static void random(){
        RandomPassword randomPassword = new RandomPassword();
        PasswordJudge passwordJudge = new PasswordJudge();
        System.out.println("=================");
        System.out.println("欢迎使用密码管理系统");
        System.out.println("=================");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入密码的长度：");
        int length = scanner.nextInt();
        System.out.println("随机的密码为："+randomPassword.randomPassword(length).toString());
    }
}